﻿using UnityEngine;
using System.Collections;

/// <summary>
/// 런처 아이템.
/// </summary>
[RequireComponent(typeof(wsLookAtSmooth))]
public class wsLauncherItem : MonoBehaviour
{
	/// <summary>
	/// 아이템 모델링 데이터.
	/// </summary>
	public GameObject model;
	/// <summary>
	/// 아이템 타이틀.
	/// </summary>
	public string title;
	/// <summary>
	/// 아이템 모델링 커버 이미지.
	/// </summary>
	public Texture coverImage;

	/// <summary>
	/// 아이템 모델링 충돌체.
	/// </summary>
	/// <value>
	/// The model collider.
	/// </value>
	public Collider ModelCollider
	{
		get
		{
			return model.collider;
		}

		private set { }
	}

	/// <summary>
	/// 아이템 사용여부.
	/// </summary>
	/// <value>
	/// <c>true</c> if enable item; otherwise, <c>false</c>.
	/// </value>
	public bool EnableItem
	{
		get
		{
			return model.renderer.enabled;
		}

		set
		{
			model.renderer.enabled = value;
		}
	}

	/// <summary>
	/// Get wsLookAtSmooth Component.
	/// </summary>
	/// <value>
	/// The look at.
	/// </value>
	public wsLookAtSmooth LookAt
	{
		get;
		private set;
	}

	void Awake()
	{
		// 3D 모델 데이터 확인.
		if (model == null)
		{
			Debug.LogError(this.gameObject.name + " : model is empty.");
		}

		// 커버 이미지 변경.
		if (coverImage)
		{
			model.renderer.material.mainTexture = coverImage;
		}

		// 타겟 바라보기.
		LookAt = this.GetComponent<wsLookAtSmooth>();
		LookAt.target = Camera.main.transform;
	}
}
